<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>将一个php变量赋值给Lua</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.lua.html">« Lua</a></li>
      <li style="float: right;"><a href="lua.call.html">Lua::call »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.lua.html">Lua</a></li>
    <li>将一个php变量赋值给Lua</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="lua.assign" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Lua::assign</h1>
  <p class="verinfo">(PECL lua &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">Lua::assign</span> &mdash; <span class="dc-title">将一个php变量赋值给Lua</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-lua.assign-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Lua::assign</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">

  </p>

  <div class="warning"><strong class="warning">警告</strong><p class="simpara">本函数还未编写文档，仅有参数列表。</p></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-lua.assign-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">name</code></dt>

    <dd>

     <p class="para">
      
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">value</code></dt>

    <dd>

     <p class="para">
      
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-lua.assign-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   赋值成功返回<var class="varname">$this</var>否则返回<strong><code>null</code></strong>
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-lua.assign-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3429">
   <p><strong>示例 #1 <span class="function"><strong>Lua::assign()</strong></span>示例</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$lua&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Lua</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$lua</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">assign</span><span style="color: #007700">(</span><span style="color: #DD0000">"php_var"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">1</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">));&nbsp;</span><span style="color: #FF8000">//lua&nbsp;table&nbsp;index&nbsp;begin&nbsp;with&nbsp;1<br /></span><span style="color: #0000BB">$lua</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">eval</span><span style="color: #007700">(&lt;&lt;&lt;CODE<br /></span><span style="color: #DD0000">&nbsp;&nbsp;&nbsp;&nbsp;print(php_var);<br /></span><span style="color: #007700">CODE<br />);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Array
 (
     [1] =&gt; 1
     [2] =&gt; 2
     [3] =&gt; 3
 )
</pre></div>
   </div>
  </div>
 </div>


</div></div></div></body></html>